package config;

import model.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

//
//@Configuration
//public class SpringConfig {
//    public SpringConfig() {
//        System.out.println("加载配置对象==>SpringConfig()!!!");
//    }
//
//    @Bean(initMethod = "initStudent1", destroyMethod = "destroyStudent1")
//    public Student student(){
//        Student student = new Student();
//        student.setStuId(1);
//        student.setStuName("张三");
//        student.setStuAge(18);
//        return student;
//    }
//}
@Configuration              //标识当前类是一个[配置类:代替xml配置文件]
public class SpringConfig {

    @Bean(value = "student", initMethod = "initStudent1", destroyMethod = "destroyStudent1")
   // @Scope(value = "prototype")
    @Scope(value = "singleton")
    public Student student() {
        Student student = new Student();
        student.setStuId(101);
        return student;
    }
}

